﻿/****** Object:  ForeignKey [FK_AlertAndNotificationRecepientUser_AlertAndNotificationRegister]    Script Date: 08/15/2016 16:34:06 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_AlertAndNotificationRecepientUser_AlertAndNotificationRegister]') AND parent_object_id = OBJECT_ID(N'[AlertAndNotificationRecepientUser]'))
ALTER TABLE [AlertAndNotificationRecepientUser] DROP CONSTRAINT [FK_AlertAndNotificationRecepientUser_AlertAndNotificationRegister]
GO
/****** Object:  ForeignKey [FK_ContentBinaryData_ContentDataMaster]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentBinaryData_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentBinaryData]'))
ALTER TABLE [ContentBinaryData] DROP CONSTRAINT [FK_ContentBinaryData_ContentDataMaster]
GO
/****** Object:  ForeignKey [FK_ContentChoiceOption_ContentDataMaster]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentChoiceOption_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentChoiceOption]'))
ALTER TABLE [ContentChoiceOption] DROP CONSTRAINT [FK_ContentChoiceOption_ContentDataMaster]
GO
/****** Object:  ForeignKey [FK_ContentChoiceResponse_ContentChoiceOption]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentChoiceResponse_ContentChoiceOption]') AND parent_object_id = OBJECT_ID(N'[ContentChoiceResponse]'))
ALTER TABLE [ContentChoiceResponse] DROP CONSTRAINT [FK_ContentChoiceResponse_ContentChoiceOption]
GO
/****** Object:  ForeignKey [FK_ContentDataMaster_ContentTypeMaster]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentDataMaster_ContentTypeMaster]') AND parent_object_id = OBJECT_ID(N'[ContentDataMaster]'))
ALTER TABLE [ContentDataMaster] DROP CONSTRAINT [FK_ContentDataMaster_ContentTypeMaster]
GO
/****** Object:  ForeignKey [FK_ContentFeedback_ContentDataMaster]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentFeedback_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentFeedback]'))
ALTER TABLE [ContentFeedback] DROP CONSTRAINT [FK_ContentFeedback_ContentDataMaster]
GO
/****** Object:  ForeignKey [FK_ContentImageData_ContentDataMaster]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentImageData_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentImageData]'))
ALTER TABLE [ContentImageData] DROP CONSTRAINT [FK_ContentImageData_ContentDataMaster]
GO
/****** Object:  ForeignKey [FK_ContentRating_ContentDataMaster]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentRating_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentRating]'))
ALTER TABLE [ContentRating] DROP CONSTRAINT [FK_ContentRating_ContentDataMaster]
GO
/****** Object:  ForeignKey [FK__Feedback__FeedbackUser]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK__Feedback__FeedbackUser]') AND parent_object_id = OBJECT_ID(N'[Feedback]'))
ALTER TABLE [Feedback] DROP CONSTRAINT [FK__Feedback__FeedbackUser]
GO
/****** Object:  ForeignKey [FK_PersonProfileImage_Person]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_PersonProfileImage_Person]') AND parent_object_id = OBJECT_ID(N'[PersonProfileImage]'))
ALTER TABLE [PersonProfileImage] DROP CONSTRAINT [FK_PersonProfileImage_Person]
GO
/****** Object:  ForeignKey [FK_Sys_ActivityMaster_Sys_ActivityTypeMaster]    Script Date: 08/15/2016 16:34:08 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_ActivityMaster_Sys_ActivityTypeMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_ActivityMaster]'))
ALTER TABLE [Sys_ActivityMaster] DROP CONSTRAINT [FK_Sys_ActivityMaster_Sys_ActivityTypeMaster]
GO
/****** Object:  ForeignKey [FK_Sys_RoleActivity_Sys_ActivityMaster]    Script Date: 08/15/2016 16:34:08 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_RoleActivity_Sys_ActivityMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_RoleActivity]'))
ALTER TABLE [Sys_RoleActivity] DROP CONSTRAINT [FK_Sys_RoleActivity_Sys_ActivityMaster]
GO
/****** Object:  ForeignKey [FK_Sys_RoleActivity_Sys_RoleMaster]    Script Date: 08/15/2016 16:34:08 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_RoleActivity_Sys_RoleMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_RoleActivity]'))
ALTER TABLE [Sys_RoleActivity] DROP CONSTRAINT [FK_Sys_RoleActivity_Sys_RoleMaster]
GO
/****** Object:  ForeignKey [FK_Sys_TableMaster_Sys_ModuleMaster]    Script Date: 08/15/2016 16:34:08 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_TableMaster_Sys_ModuleMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_TableMaster]'))
ALTER TABLE [Sys_TableMaster] DROP CONSTRAINT [FK_Sys_TableMaster_Sys_ModuleMaster]
GO
/****** Object:  ForeignKey [FK_User_Person]    Script Date: 08/15/2016 16:34:09 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_User_Person]') AND parent_object_id = OBJECT_ID(N'[User]'))
ALTER TABLE [User] DROP CONSTRAINT [FK_User_Person]
GO
/****** Object:  ForeignKey [FK_UserRole_Sys_OrganizationMaster]    Script Date: 08/15/2016 16:34:09 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_Sys_OrganizationMaster]') AND parent_object_id = OBJECT_ID(N'[UserOrganizationRole]'))
ALTER TABLE [UserOrganizationRole] DROP CONSTRAINT [FK_UserRole_Sys_OrganizationMaster]
GO
/****** Object:  ForeignKey [FK_UserRole_Sys_RoleMaster]    Script Date: 08/15/2016 16:34:09 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_Sys_RoleMaster]') AND parent_object_id = OBJECT_ID(N'[UserOrganizationRole]'))
ALTER TABLE [UserOrganizationRole] DROP CONSTRAINT [FK_UserRole_Sys_RoleMaster]
GO
/****** Object:  ForeignKey [FK_UserRole_User]    Script Date: 08/15/2016 16:34:09 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_User]') AND parent_object_id = OBJECT_ID(N'[UserOrganizationRole]'))
ALTER TABLE [UserOrganizationRole] DROP CONSTRAINT [FK_UserRole_User]
GO
/****** Object:  Table [ContentChoiceResponse]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentChoiceResponse_ContentChoiceOption]') AND parent_object_id = OBJECT_ID(N'[ContentChoiceResponse]'))
ALTER TABLE [ContentChoiceResponse] DROP CONSTRAINT [FK_ContentChoiceResponse_ContentChoiceOption]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentChoiceResponse]') AND type in (N'U'))
DROP TABLE [ContentChoiceResponse]
GO
/****** Object:  Table [ContentBinaryData]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentBinaryData_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentBinaryData]'))
ALTER TABLE [ContentBinaryData] DROP CONSTRAINT [FK_ContentBinaryData_ContentDataMaster]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentBinaryData]') AND type in (N'U'))
DROP TABLE [ContentBinaryData]
GO
/****** Object:  Table [ContentChoiceOption]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentChoiceOption_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentChoiceOption]'))
ALTER TABLE [ContentChoiceOption] DROP CONSTRAINT [FK_ContentChoiceOption_ContentDataMaster]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentChoiceOption]') AND type in (N'U'))
DROP TABLE [ContentChoiceOption]
GO
/****** Object:  Table [ContentFeedback]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentFeedback_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentFeedback]'))
ALTER TABLE [ContentFeedback] DROP CONSTRAINT [FK_ContentFeedback_ContentDataMaster]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentFeedback]') AND type in (N'U'))
DROP TABLE [ContentFeedback]
GO
/****** Object:  Table [ContentImageData]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentImageData_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentImageData]'))
ALTER TABLE [ContentImageData] DROP CONSTRAINT [FK_ContentImageData_ContentDataMaster]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentImageData]') AND type in (N'U'))
DROP TABLE [ContentImageData]
GO
/****** Object:  Table [ContentRating]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentRating_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentRating]'))
ALTER TABLE [ContentRating] DROP CONSTRAINT [FK_ContentRating_ContentDataMaster]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentRating]') AND type in (N'U'))
DROP TABLE [ContentRating]
GO
/****** Object:  Table [Sys_RoleActivity]    Script Date: 08/15/2016 16:34:08 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_RoleActivity_Sys_ActivityMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_RoleActivity]'))
ALTER TABLE [Sys_RoleActivity] DROP CONSTRAINT [FK_Sys_RoleActivity_Sys_ActivityMaster]
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_RoleActivity_Sys_RoleMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_RoleActivity]'))
ALTER TABLE [Sys_RoleActivity] DROP CONSTRAINT [FK_Sys_RoleActivity_Sys_RoleMaster]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_RoleActivity]') AND type in (N'U'))
DROP TABLE [Sys_RoleActivity]
GO
/****** Object:  Table [UserOrganizationRole]    Script Date: 08/15/2016 16:34:09 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_Sys_OrganizationMaster]') AND parent_object_id = OBJECT_ID(N'[UserOrganizationRole]'))
ALTER TABLE [UserOrganizationRole] DROP CONSTRAINT [FK_UserRole_Sys_OrganizationMaster]
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_Sys_RoleMaster]') AND parent_object_id = OBJECT_ID(N'[UserOrganizationRole]'))
ALTER TABLE [UserOrganizationRole] DROP CONSTRAINT [FK_UserRole_Sys_RoleMaster]
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_User]') AND parent_object_id = OBJECT_ID(N'[UserOrganizationRole]'))
ALTER TABLE [UserOrganizationRole] DROP CONSTRAINT [FK_UserRole_User]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[UserOrganizationRole]') AND type in (N'U'))
DROP TABLE [UserOrganizationRole]
GO
/****** Object:  Table [User]    Script Date: 08/15/2016 16:34:09 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_User_Person]') AND parent_object_id = OBJECT_ID(N'[User]'))
ALTER TABLE [User] DROP CONSTRAINT [FK_User_Person]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[User]') AND type in (N'U'))
DROP TABLE [User]
GO
/****** Object:  Table [PersonProfileImage]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_PersonProfileImage_Person]') AND parent_object_id = OBJECT_ID(N'[PersonProfileImage]'))
ALTER TABLE [PersonProfileImage] DROP CONSTRAINT [FK_PersonProfileImage_Person]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[PersonProfileImage]') AND type in (N'U'))
DROP TABLE [PersonProfileImage]
GO
/****** Object:  Table [Sys_TableMaster]    Script Date: 08/15/2016 16:34:08 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_TableMaster_Sys_ModuleMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_TableMaster]'))
ALTER TABLE [Sys_TableMaster] DROP CONSTRAINT [FK_Sys_TableMaster_Sys_ModuleMaster]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_TableMaster]') AND type in (N'U'))
DROP TABLE [Sys_TableMaster]
GO
/****** Object:  Table [Sys_ActivityMaster]    Script Date: 08/15/2016 16:34:08 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_ActivityMaster_Sys_ActivityTypeMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_ActivityMaster]'))
ALTER TABLE [Sys_ActivityMaster] DROP CONSTRAINT [FK_Sys_ActivityMaster_Sys_ActivityTypeMaster]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_ActivityMaster]') AND type in (N'U'))
DROP TABLE [Sys_ActivityMaster]
GO
/****** Object:  Table [Feedback]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK__Feedback__FeedbackUser]') AND parent_object_id = OBJECT_ID(N'[Feedback]'))
ALTER TABLE [Feedback] DROP CONSTRAINT [FK__Feedback__FeedbackUser]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Feedback]') AND type in (N'U'))
DROP TABLE [Feedback]
GO
/****** Object:  Table [AlertAndNotificationRecepientUser]    Script Date: 08/15/2016 16:34:06 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_AlertAndNotificationRecepientUser_AlertAndNotificationRegister]') AND parent_object_id = OBJECT_ID(N'[AlertAndNotificationRecepientUser]'))
ALTER TABLE [AlertAndNotificationRecepientUser] DROP CONSTRAINT [FK_AlertAndNotificationRecepientUser_AlertAndNotificationRegister]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[AlertAndNotificationRecepientUser]') AND type in (N'U'))
DROP TABLE [AlertAndNotificationRecepientUser]
GO
/****** Object:  Table [ContentDataMaster]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentDataMaster_ContentTypeMaster]') AND parent_object_id = OBJECT_ID(N'[ContentDataMaster]'))
ALTER TABLE [ContentDataMaster] DROP CONSTRAINT [FK_ContentDataMaster_ContentTypeMaster]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentDataMaster]') AND type in (N'U'))
DROP TABLE [ContentDataMaster]
GO
/****** Object:  Table [AlertAndNotificationRegister]    Script Date: 08/15/2016 16:34:06 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[AlertAndNotificationRegister]') AND type in (N'U'))
DROP TABLE [AlertAndNotificationRegister]
GO
/****** Object:  Table [FeedbackUser]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[FeedbackUser]') AND type in (N'U'))
DROP TABLE [FeedbackUser]
GO
/****** Object:  Table [Person]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Person]') AND type in (N'U'))
DROP TABLE [Person]
GO
/****** Object:  Table [ContentTypeMaster]    Script Date: 08/15/2016 16:34:07 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentTypeMaster]') AND type in (N'U'))
DROP TABLE [ContentTypeMaster]
GO
/****** Object:  Table [Sys_ActivityTypeMaster]    Script Date: 08/15/2016 16:34:08 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_ActivityTypeMaster]') AND type in (N'U'))
DROP TABLE [Sys_ActivityTypeMaster]
GO
/****** Object:  Table [Sys_ErrorLog]    Script Date: 08/15/2016 16:34:08 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_ErrorLog]') AND type in (N'U'))
DROP TABLE [Sys_ErrorLog]
GO
/****** Object:  Table [Sys_LoginHistoryLog]    Script Date: 08/15/2016 16:34:08 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_LoginHistoryLog]') AND type in (N'U'))
DROP TABLE [Sys_LoginHistoryLog]
GO
/****** Object:  Table [Sys_ModuleMaster]    Script Date: 08/15/2016 16:34:08 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_ModuleMaster]') AND type in (N'U'))
DROP TABLE [Sys_ModuleMaster]
GO
/****** Object:  Table [Sys_OrganizationMaster]    Script Date: 08/15/2016 16:34:08 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_OrganizationMaster]') AND type in (N'U'))
DROP TABLE [Sys_OrganizationMaster]
GO
/****** Object:  Table [TaskRegister]    Script Date: 08/15/2016 16:34:08 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[TaskRegister]') AND type in (N'U'))
DROP TABLE [TaskRegister]
GO
/****** Object:  Table [ProjectMemberMaster]    Script Date: 08/15/2016 16:34:08 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ProjectMemberMaster]') AND type in (N'U'))
DROP TABLE [ProjectMemberMaster]
GO
/****** Object:  Table [Subscription]    Script Date: 08/15/2016 16:34:08 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Subscription]') AND type in (N'U'))
DROP TABLE [Subscription]
GO
/****** Object:  Table [Sys_RoleMaster]    Script Date: 08/15/2016 16:34:08 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_RoleMaster]') AND type in (N'U'))
DROP TABLE [Sys_RoleMaster]
GO
/****** Object:  Table [Sys_SessionLog]    Script Date: 08/15/2016 16:34:08 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_SessionLog]') AND type in (N'U'))
DROP TABLE [Sys_SessionLog]
GO
/****** Object:  Table [Sys_SessionLog]    Script Date: 08/15/2016 16:34:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_SessionLog]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_SessionLog](
	[SessionLogPrimaryID] [int] IDENTITY(1,1) NOT NULL,
	[UserSessionID] [varchar](500) NOT NULL,
	[UserIPAddress] [varchar](50) NULL,
	[UserSessionStartTime] [datetime] NOT NULL,
	[UserSessionEndTime] [datetime] NULL,
	[UserBrowserName] [varchar](150) NULL,
	[UserKey] [int] NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Sys_SessionLog] PRIMARY KEY CLUSTERED 
(
	[SessionLogPrimaryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_SessionLog', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_SessionLog', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_SessionLog', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_SessionLog', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_SessionLog', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_SessionLog', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_SessionLog', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_SessionLog', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_SessionLog', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_SessionLog', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Sys_RoleMaster]    Script Date: 08/15/2016 16:34:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_RoleMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_RoleMaster](
	[RoleKey] [int] IDENTITY(1,1) NOT NULL,
	[RoleCode] [varchar](50) NOT NULL,
	[RoleName] [varchar](150) NOT NULL,
	[RoleDescription] [varchar](1000) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Sys_RoleMaster] PRIMARY KEY CLUSTERED 
(
	[RoleKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [Unique_RoleCode] UNIQUE NONCLUSTERED 
(
	[RoleCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [Unique_RoleName] UNIQUE NONCLUSTERED 
(
	[RoleName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_RoleMaster', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleMaster', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_RoleMaster', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleMaster', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_RoleMaster', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleMaster', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_RoleMaster', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleMaster', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_RoleMaster', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleMaster', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Subscription]    Script Date: 08/15/2016 16:34:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Subscription]') AND type in (N'U'))
BEGIN
CREATE TABLE [Subscription](
	[SubscribKey] [int] IDENTITY(1,1) NOT NULL,
	[SubscribItemCode] [int] NULL,
	[SubscribItemDescription] [varchar](1000) NULL,
	[SubscribUserMailID] [varchar](150) NULL,
	[SubscrbDate] [datetime] NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_SubscriptionMaster] PRIMARY KEY CLUSTERED 
(
	[SubscribKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [ProjectMemberMaster]    Script Date: 08/15/2016 16:34:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ProjectMemberMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [ProjectMemberMaster](
	[ProjectMemberKey] [int] IDENTITY(1,1) NOT NULL,
	[ProjectMemberUserKey] [int] NULL,
	[ProjectMemberFirstName] [varchar](50) NOT NULL,
	[ProjectMemberLastName] [varchar](50) NULL,
	[ProjectMemberPrimaryEmailID] [varchar](150) NOT NULL,
	[ProjectMemberCodePlexID] [varchar](50) NOT NULL,
	[ProjectMemberSkypeID] [varchar](50) NOT NULL,
	[ProjectMemberMicrosoftID] [varchar](50) NULL,
	[ProjectMemberGoogleID] [varchar](50) NULL,
	[ProjectMemberTimeZoneReference] [varchar](50) NULL,
	[ProjectMemberTimeZoneName] [varchar](250) NULL,
	[ProjectMemberTimeZoneAbbreviation] [varchar](50) NULL,
	[ProjectMemberCountryName] [varchar](150) NULL,
	[ProjectMemberCityName] [varchar](150) NULL,
	[ProjectMemberDateOfJoining] [datetime] NULL,
	[ProjectMemberIsMemberOfFacebook] [bit] NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_ProjectMemberMaster] PRIMARY KEY CLUSTERED 
(
	[ProjectMemberKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[ProjectMemberMaster]') AND name = N'ProjectMember_UniqueEmailID')
CREATE UNIQUE NONCLUSTERED INDEX [ProjectMember_UniqueEmailID] ON [ProjectMemberMaster] 
(
	[ProjectMemberPrimaryEmailID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ProjectMemberMaster', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ProjectMemberMaster', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ProjectMemberMaster', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ProjectMemberMaster', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ProjectMemberMaster', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ProjectMemberMaster', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ProjectMemberMaster', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ProjectMemberMaster', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ProjectMemberMaster', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ProjectMemberMaster', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [TaskRegister]    Script Date: 08/15/2016 16:34:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[TaskRegister]') AND type in (N'U'))
BEGIN
CREATE TABLE [TaskRegister](
	[TaskKey] [int] IDENTITY(1,1) NOT NULL,
	[TaskTitle] [varchar](200) NOT NULL,
	[TaskDescrition] [varchar](max) NULL,
	[TaskStatus] [int] NOT NULL,
	[TaskStatusChangeDateTime] [datetime] NOT NULL,
	[TaskDiscussion] [varchar](max) NULL,
	[TaskCompletionRemainingHours] [int] NULL,
	[TaskPriority] [int] NULL,
	[TaskCompletionPercentage] [int] NULL,
	[TaskAssignedToUserKey] [int] NULL,
	[TaskAssignmentDateTime] [datetime] NULL,
	[DependentOnTaskKey] [int] NULL,
	[AssociatedParentTaskKey] [int] NULL,
	[TaskAssociatedContentKey] [int] NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_TaskRegister] PRIMARY KEY CLUSTERED 
(
	[TaskKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'TaskRegister', N'COLUMN',N'TaskStatus'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'1= Approved, 2= WorkInProgress, 3=Done, 4=OnHold, 5=Discarded' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'TaskRegister', @level2type=N'COLUMN',@level2name=N'TaskStatus'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'TaskRegister', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'TaskRegister', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'TaskRegister', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'TaskRegister', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'TaskRegister', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'TaskRegister', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'TaskRegister', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'TaskRegister', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'TaskRegister', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'TaskRegister', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Sys_OrganizationMaster]    Script Date: 08/15/2016 16:34:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_OrganizationMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_OrganizationMaster](
	[OrganizationID] [int] IDENTITY(1,1) NOT NULL,
	[OrganizationCode] [varchar](50) NOT NULL,
	[OrganizationName] [varchar](200) NOT NULL,
	[OrganizationDescription] [nvarchar](max) NULL,
	[OrganizationDomainURL] [varchar](max) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Sys_OrganizationMaster] PRIMARY KEY CLUSTERED 
(
	[OrganizationID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [Unique_Sys_OrganizationCode] UNIQUE NONCLUSTERED 
(
	[OrganizationCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_OrganizationMaster', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_OrganizationMaster', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_OrganizationMaster', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_OrganizationMaster', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_OrganizationMaster', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_OrganizationMaster', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_OrganizationMaster', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_OrganizationMaster', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_OrganizationMaster', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_OrganizationMaster', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Sys_ModuleMaster]    Script Date: 08/15/2016 16:34:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_ModuleMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_ModuleMaster](
	[ModuleID] [int] NOT NULL,
	[ModuleName] [varchar](50) NOT NULL,
	[ModuleDescription] [nvarchar](max) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Sys_ModuleMaster] PRIMARY KEY CLUSTERED 
(
	[ModuleID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ModuleMaster', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ModuleMaster', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ModuleMaster', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ModuleMaster', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ModuleMaster', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ModuleMaster', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ModuleMaster', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ModuleMaster', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ModuleMaster', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ModuleMaster', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Sys_LoginHistoryLog]    Script Date: 08/15/2016 16:34:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_LoginHistoryLog]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_LoginHistoryLog](
	[LoginKey] [int] IDENTITY(1,1) NOT NULL,
	[LoginUserKey] [int] NOT NULL,
	[LoginUserLoginID] [varchar](50) NOT NULL,
	[LoginStartTime] [datetime] NOT NULL,
	[LoginEndTime] [datetime] NULL,
	[LoginUserBrowser] [varchar](50) NULL,
	[LoginLocation] [varchar](150) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_LoginHistoryLog] PRIMARY KEY CLUSTERED 
(
	[LoginKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_LoginHistoryLog', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_LoginHistoryLog', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_LoginHistoryLog', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_LoginHistoryLog', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_LoginHistoryLog', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_LoginHistoryLog', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_LoginHistoryLog', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_LoginHistoryLog', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_LoginHistoryLog', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_LoginHistoryLog', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Sys_ErrorLog]    Script Date: 08/15/2016 16:34:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_ErrorLog]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_ErrorLog](
	[ErrorLogPrimaryID] [int] IDENTITY(1,1) NOT NULL,
	[ApplicationName] [varchar](500) NULL,
	[MethodName] [varchar](500) NULL,
	[ErrorMessage] [varchar](max) NOT NULL,
	[StackTrace] [varchar](max) NOT NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Sys_ErrorLog_1] PRIMARY KEY CLUSTERED 
(
	[ErrorLogPrimaryID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ErrorLog', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ErrorLog', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ErrorLog', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ErrorLog', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ErrorLog', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ErrorLog', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ErrorLog', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ErrorLog', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ErrorLog', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ErrorLog', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Sys_ActivityTypeMaster]    Script Date: 08/15/2016 16:34:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_ActivityTypeMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_ActivityTypeMaster](
	[ActivityTypeKey] [int] IDENTITY(1,1) NOT NULL,
	[ActivityTypeCode] [varchar](50) NOT NULL,
	[ActivityTypeName] [varchar](150) NOT NULL,
	[ActivityTypeDescription] [varchar](1000) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Sys_ActivityTypeMaster] PRIMARY KEY CLUSTERED 
(
	[ActivityTypeKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ActivityTypeMaster', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ActivityTypeMaster', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ActivityTypeMaster', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ActivityTypeMaster', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ActivityTypeMaster', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [ContentTypeMaster]    Script Date: 08/15/2016 16:34:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentTypeMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [ContentTypeMaster](
	[ContentTypeKey] [int] IDENTITY(1,1) NOT NULL,
	[ContentTypeCode] [varchar](50) NOT NULL,
	[ContentTypeName] [varchar](150) NOT NULL,
	[ContentDescription] [varchar](500) NULL,
	[ContentTotalNumberOfAttachments] [int] NOT NULL,
	[ContentAttachmentStoreLocationType] [int] NOT NULL,
	[ContentTotalNumberOfImages] [int] NOT NULL,
	[ContentImageStoreLocationType] [int] NOT NULL,
	[ContentTotalNumberOfVideos] [int] NOT NULL,
	[ContentTotalNumberOfAudios] [int] NOT NULL,
	[ContentTotalNumberOfChoiceOptions] [int] NOT NULL,
	[ContentChoiceOptionType] [int] NOT NULL,
	[ContentVisibilityType] [int] NOT NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_ContentTypeMaster] PRIMARY KEY CLUSTERED 
(
	[ContentTypeKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[ContentTypeMaster]') AND name = N'Unique_ContentTypeMaster')
CREATE UNIQUE NONCLUSTERED INDEX [Unique_ContentTypeMaster] ON [ContentTypeMaster] 
(
	[ContentTypeCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentTypeMaster', N'COLUMN',N'ContentAttachmentStoreLocationType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Not Applicable, 1=In ContentBinaryData Table, 2=In Server Local Folder' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentTypeMaster', @level2type=N'COLUMN',@level2name=N'ContentAttachmentStoreLocationType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentTypeMaster', N'COLUMN',N'ContentImageStoreLocationType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Not Applicable, 1=In ContentImageData Table, 2=In Server Local Folder' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentTypeMaster', @level2type=N'COLUMN',@level2name=N'ContentImageStoreLocationType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentTypeMaster', N'COLUMN',N'ContentChoiceOptionType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Not Applicable, 1=Single Selection allowed, 2- Multiple Selection Allowed' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentTypeMaster', @level2type=N'COLUMN',@level2name=N'ContentChoiceOptionType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentTypeMaster', N'COLUMN',N'ContentVisibilityType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'1= Anyone including Guests, 2= Any Registered Users, 3=Any Member of an Sepcific Organization, 4= Admin Members of an Organization, 5=Admin Member of  System Portal, 6= Non-Admin Member of System Portal' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentTypeMaster', @level2type=N'COLUMN',@level2name=N'ContentVisibilityType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentTypeMaster', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentTypeMaster', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentTypeMaster', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentTypeMaster', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentTypeMaster', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentTypeMaster', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Person]    Script Date: 08/15/2016 16:34:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Person]') AND type in (N'U'))
BEGIN
CREATE TABLE [Person](
	[PersonKey] [int] IDENTITY(1,1) NOT NULL,
	[PersonFirstName] [varchar](100) NOT NULL,
	[PersonLastName] [varchar](100) NULL,
	[PersonSex] [char](1) NULL,
	[PersonDateOfBirth] [datetime] NULL,
	[PersonPrimaryEmailID] [varchar](200) NULL,
	[PersonPrimaryEmailVerificationCode] [varchar](50) NULL,
	[PersonPrimaryEmailIsVerified] [bit] NOT NULL,
	[PersonAlternateEmailID] [varchar](200) NULL,
	[PersonPrimaryMobileNumber] [varchar](50) NULL,
	[PersonPrimaryMobileVerificationCode] [varchar](50) NULL,
	[PersonPrimaryMobileIsVerified] [bit] NOT NULL,
	[PersonAlternatePhoneNumber] [varchar](50) NULL,
	[PersonAddressLine1] [varchar](300) NULL,
	[PersonAddressLine2] [varchar](300) NULL,
	[PersonAddressCityName] [varchar](200) NULL,
	[PersonAddressStateName] [varchar](200) NULL,
	[PersonAddressCountryName] [varchar](200) NULL,
	[PersonAddressPinZipCode] [varchar](50) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_PersonKey] PRIMARY KEY CLUSTERED 
(
	[PersonKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [Unique_Person] UNIQUE NONCLUSTERED 
(
	[PersonFirstName] ASC,
	[PersonLastName] ASC,
	[PersonDateOfBirth] ASC,
	[PersonPrimaryEmailID] ASC,
	[PersonPrimaryMobileNumber] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Person', N'COLUMN',N'PersonSex'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'M=Male; F=Female' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Person', @level2type=N'COLUMN',@level2name=N'PersonSex'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Person', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Person', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Person', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Person', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Person', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Person', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Person', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Person', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Person', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Person', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [FeedbackUser]    Script Date: 08/15/2016 16:34:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[FeedbackUser]') AND type in (N'U'))
BEGIN
CREATE TABLE [FeedbackUser](
	[FeedbackUserKey] [int] IDENTITY(1,1) NOT NULL,
	[FeedbackUserName] [varchar](150) NOT NULL,
	[FeedbackUserEmail] [varchar](150) NOT NULL,
	[RegisteredUserKey] [int] NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_FeedbackUser] PRIMARY KEY CLUSTERED 
(
	[FeedbackUserKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [Unique_FeedbackUserEmail] UNIQUE NONCLUSTERED 
(
	[FeedbackUserEmail] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [FeedbackUser] SET (LOCK_ESCALATION = AUTO)
GO
/****** Object:  Table [AlertAndNotificationRegister]    Script Date: 08/15/2016 16:34:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[AlertAndNotificationRegister]') AND type in (N'U'))
BEGIN
CREATE TABLE [AlertAndNotificationRegister](
	[AlertNotificationKey] [int] IDENTITY(1,1) NOT NULL,
	[AlertNotificationDescription] [varchar](max) NOT NULL,
	[AlertNotificationDistrubutionType] [int] NOT NULL,
	[AlertNotificationSenderUserKey] [int] NOT NULL,
	[AlertNotificationRecepientComaSeperatedUserKeys] [varchar](max) NULL,
	[AlertNotificationAssociatedContentKey] [int] NULL,
	[AlertNotificationStatus] [int] NOT NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_AlertAndNotificationRegister_1] PRIMARY KEY CLUSTERED 
(
	[AlertNotificationKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'AlertAndNotificationRegister', N'COLUMN',N'AlertNotificationDistrubutionType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'1= For all registered System Users, 2= For all registered organization members, 3= For specific set of registered users' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'AlertAndNotificationRegister', @level2type=N'COLUMN',@level2name=N'AlertNotificationDistrubutionType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'AlertAndNotificationRegister', N'COLUMN',N'AlertNotificationRecepientComaSeperatedUserKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Coma seperated user keys, and will be NULL for AlertNotificationDistrubutionType 1 and 2' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'AlertAndNotificationRegister', @level2type=N'COLUMN',@level2name=N'AlertNotificationRecepientComaSeperatedUserKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'AlertAndNotificationRegister', N'COLUMN',N'AlertNotificationStatus'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'1=Draft, 2=Published or Sent, 3=Scheduled' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'AlertAndNotificationRegister', @level2type=N'COLUMN',@level2name=N'AlertNotificationStatus'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'AlertAndNotificationRegister', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'AlertAndNotificationRegister', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'AlertAndNotificationRegister', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'AlertAndNotificationRegister', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'AlertAndNotificationRegister', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'AlertAndNotificationRegister', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'AlertAndNotificationRegister', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'AlertAndNotificationRegister', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'AlertAndNotificationRegister', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'AlertAndNotificationRegister', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [ContentDataMaster]    Script Date: 08/15/2016 16:34:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentDataMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [ContentDataMaster](
	[ContentKey] [int] IDENTITY(1,1) NOT NULL,
	[ContentCode] [varchar](50) NOT NULL,
	[ContentName] [varchar](200) NOT NULL,
	[ContentTypeKey] [int] NOT NULL,
	[ContentStatus] [int] NOT NULL,
	[ContentPublicationStartDate] [datetime] NULL,
	[ContentPublicationEndDate] [datetime] NULL,
	[ContentHtmlData] [varchar](max) NOT NULL,
	[ContentMetaTagKeyword] [varchar](max) NULL,
	[ContentMetaTagDescription] [varchar](max) NULL,
	[ContentTotalDownloads] [int] NULL,
	[ContentTotalLikes] [int] NULL,
	[ContentTotalViews] [int] NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_ContentMetaDataMaster] PRIMARY KEY CLUSTERED 
(
	[ContentKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [Unique_ContentDataMaster_ContentCode] UNIQUE NONCLUSTERED 
(
	[ContentKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentDataMaster', N'COLUMN',N'ContentTypeKey'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentDataMaster', @level2type=N'COLUMN',@level2name=N'ContentTypeKey'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentDataMaster', N'COLUMN',N'ContentStatus'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'1=Draft, 2=Published to live, 3=Scheduled to live for a period' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentDataMaster', @level2type=N'COLUMN',@level2name=N'ContentStatus'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentDataMaster', N'COLUMN',N'ContentMetaTagKeyword'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Seach Keywords seperated by comma (,)' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentDataMaster', @level2type=N'COLUMN',@level2name=N'ContentMetaTagKeyword'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentDataMaster', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentDataMaster', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentDataMaster', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentDataMaster', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentDataMaster', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentDataMaster', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentDataMaster', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentDataMaster', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentDataMaster', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentDataMaster', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [AlertAndNotificationRecepientUser]    Script Date: 08/15/2016 16:34:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[AlertAndNotificationRecepientUser]') AND type in (N'U'))
BEGIN
CREATE TABLE [AlertAndNotificationRecepientUser](
	[AlertNotificationKey] [int] NOT NULL,
	[AlertNotificationEmail] [varchar](150) NOT NULL,
	[AlertNotificationUserName] [varchar](150) NULL,
	[AlertNotificationRecepientUserKey] [int] NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_AlertAndNotificationRecepientUser_1] PRIMARY KEY CLUSTERED 
(
	[AlertNotificationKey] ASC,
	[AlertNotificationEmail] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [Feedback]    Script Date: 08/15/2016 16:34:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Feedback]') AND type in (N'U'))
BEGIN
CREATE TABLE [Feedback](
	[FeedbackKey] [int] IDENTITY(1,1) NOT NULL,
	[FeedbackUserKey] [int] NOT NULL,
	[FeedbackSubject] [varchar](200) NULL,
	[FeedbackText] [varchar](max) NOT NULL,
	[FeedbackDate] [datetime] NOT NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Feedback] PRIMARY KEY CLUSTERED 
(
	[FeedbackKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [Feedback] SET (LOCK_ESCALATION = AUTO)
GO
/****** Object:  Table [Sys_ActivityMaster]    Script Date: 08/15/2016 16:34:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_ActivityMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_ActivityMaster](
	[ActivityKey] [int] IDENTITY(1,1) NOT NULL,
	[ActivityCode] [varchar](50) NOT NULL,
	[ActivityName] [varchar](150) NOT NULL,
	[ActivityDescription] [varchar](1000) NULL,
	[ActivityTypeKey] [int] NOT NULL,
	[ActivityTypeCode] [varchar](50) NOT NULL,
	[ActivityTypeName] [varchar](150) NOT NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Sys_ActivityMaster] PRIMARY KEY CLUSTERED 
(
	[ActivityKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[Sys_ActivityMaster]') AND name = N'Unique _ActivityMasterCode')
CREATE UNIQUE NONCLUSTERED INDEX [Unique _ActivityMasterCode] ON [Sys_ActivityMaster] 
(
	[ActivityCode] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[Sys_ActivityMaster]') AND name = N'Unique_ActivityMasterName')
CREATE UNIQUE NONCLUSTERED INDEX [Unique_ActivityMasterName] ON [Sys_ActivityMaster] 
(
	[ActivityName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ActivityMaster', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityMaster', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ActivityMaster', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityMaster', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ActivityMaster', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityMaster', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ActivityMaster', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityMaster', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_ActivityMaster', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_ActivityMaster', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Sys_TableMaster]    Script Date: 08/15/2016 16:34:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_TableMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_TableMaster](
	[TableID] [int] NOT NULL,
	[TableName] [varchar](50) NOT NULL,
	[TableDescription] [varchar](max) NULL,
	[TableSequenceNo] [int] NULL,
	[ModuleID] [int] NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Sys_TableMaster] PRIMARY KEY CLUSTERED 
(
	[TableID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_TableMaster', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_TableMaster', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_TableMaster', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_TableMaster', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_TableMaster', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_TableMaster', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_TableMaster', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_TableMaster', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_TableMaster', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_TableMaster', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [PersonProfileImage]    Script Date: 08/15/2016 16:34:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[PersonProfileImage]') AND type in (N'U'))
BEGIN
CREATE TABLE [PersonProfileImage](
	[PersonKey] [int] NOT NULL,
	[PersonProfileImageData] [varbinary](max) NULL,
	[PersonImageType] [varchar](1000) NULL,
	[PersonImageFileName] [varchar](1000) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_PersonProfileImage] PRIMARY KEY CLUSTERED 
(
	[PersonKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'PersonProfileImage', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'PersonProfileImage', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'PersonProfileImage', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'PersonProfileImage', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'PersonProfileImage', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'PersonProfileImage', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'PersonProfileImage', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'PersonProfileImage', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'PersonProfileImage', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'PersonProfileImage', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [User]    Script Date: 08/15/2016 16:34:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[User]') AND type in (N'U'))
BEGIN
CREATE TABLE [User](
	[UserPersonKey] [int] NOT NULL,
	[UserLoginId] [varchar](50) NOT NULL,
	[UserPassword] [varchar](50) NULL,
	[UserLoginIdType] [int] NOT NULL,
	[UserForgotPasswordQuestion] [varchar](300) NULL,
	[UserForgotPasswordAnswer] [varchar](300) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_User] PRIMARY KEY CLUSTERED 
(
	[UserPersonKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'User', N'COLUMN',N'UserLoginIdType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'1=Portal Unique Login Id; 2=Primary Email; 3=Facebook; 4=Twitter; 5=Google; 6=Microsoft; LinkedIn' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'UserLoginIdType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'User', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'User', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'User', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'User', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'User', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [UserOrganizationRole]    Script Date: 08/15/2016 16:34:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[UserOrganizationRole]') AND type in (N'U'))
BEGIN
CREATE TABLE [UserOrganizationRole](
	[UserKey] [int] NOT NULL,
	[UserOrganizationKey] [int] NOT NULL,
	[UserRoleKey] [int] NOT NULL,
	[UserLoginID] [varchar](50) NOT NULL,
	[UserOrganizationCode] [varchar](50) NOT NULL,
	[UserOrganizationName] [varchar](200) NOT NULL,
	[UserRoleCode] [varchar](50) NOT NULL,
	[UserRoleName] [varchar](150) NOT NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_UserRole] PRIMARY KEY CLUSTERED 
(
	[UserKey] ASC,
	[UserOrganizationKey] ASC,
	[UserRoleKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'UserOrganizationRole', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'UserOrganizationRole', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'UserOrganizationRole', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'UserOrganizationRole', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'UserOrganizationRole', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'UserOrganizationRole', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'UserOrganizationRole', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'UserOrganizationRole', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'UserOrganizationRole', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'UserOrganizationRole', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [Sys_RoleActivity]    Script Date: 08/15/2016 16:34:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Sys_RoleActivity]') AND type in (N'U'))
BEGIN
CREATE TABLE [Sys_RoleActivity](
	[RoleKey] [int] NOT NULL,
	[RoleActivityKey] [int] NOT NULL,
	[RoleCode] [varchar](50) NOT NULL,
	[RoleName] [varchar](150) NOT NULL,
	[ActivityCode] [varchar](50) NOT NULL,
	[ActivityName] [varchar](150) NOT NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_Sys_RoleActivity] PRIMARY KEY CLUSTERED 
(
	[RoleKey] ASC,
	[RoleActivityKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_RoleActivity', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleActivity', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_RoleActivity', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleActivity', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_RoleActivity', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleActivity', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_RoleActivity', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleActivity', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'Sys_RoleActivity', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'Sys_RoleActivity', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [ContentRating]    Script Date: 08/15/2016 16:34:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentRating]') AND type in (N'U'))
BEGIN
CREATE TABLE [ContentRating](
	[ContentRatingKey] [int] IDENTITY(1,1) NOT NULL,
	[ContentKey] [int] NOT NULL,
	[ContentRatingValue] [int] NOT NULL,
	[ContentRatingDate] [datetime] NOT NULL,
	[ContentRatingProviderUserKey] [int] NULL,
	[ContentRatingProviderName] [varchar](150) NULL,
	[ContentRatingProviderEmail] [varchar](150) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_ContentRating] PRIMARY KEY CLUSTERED 
(
	[ContentRatingKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentRating', N'COLUMN',N'ContentRatingValue'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Number in a scale of 1 to 5.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentRating', @level2type=N'COLUMN',@level2name=N'ContentRatingValue'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentRating', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentRating', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentRating', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentRating', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentRating', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentRating', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentRating', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentRating', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentRating', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentRating', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [ContentImageData]    Script Date: 08/15/2016 16:34:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentImageData]') AND type in (N'U'))
BEGIN
CREATE TABLE [ContentImageData](
	[ContentImageKey] [int] IDENTITY(1,1) NOT NULL,
	[ContentKey] [int] NOT NULL,
	[ContentImageData] [varbinary](max) NOT NULL,
	[ContentImageType] [varchar](1000) NULL,
	[ContentImageFileName] [varchar](1000) NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_ContentImageDataContent_1] PRIMARY KEY CLUSTERED 
(
	[ContentImageKey] ASC,
	[ContentKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentImageData', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentImageData', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentImageData', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentImageData', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentImageData', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentImageData', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentImageData', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentImageData', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentImageData', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentImageData', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [ContentFeedback]    Script Date: 08/15/2016 16:34:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentFeedback]') AND type in (N'U'))
BEGIN
CREATE TABLE [ContentFeedback](
	[ContentFeedbackKey] [int] IDENTITY(1,1) NOT NULL,
	[ContentKey] [int] NOT NULL,
	[ContentFeedbackFeedbackKey] [int] NULL,
	[ContentFeedbackText] [varchar](max) NOT NULL,
	[ContentFeedbackDate] [datetime] NOT NULL,
	[ContentFeedbackAuthorUserKey] [int] NULL,
	[ContentFeedbackAuthorName] [varchar](150) NOT NULL,
	[ContentFeedbackAuthorEmail] [varchar](150) NOT NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_ContentFeedback] PRIMARY KEY CLUSTERED 
(
	[ContentFeedbackKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentFeedback', N'COLUMN',N'ContentKey'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Foreign Key to main content.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentFeedback', @level2type=N'COLUMN',@level2name=N'ContentKey'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentFeedback', N'COLUMN',N'ContentFeedbackFeedbackKey'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Generally will be Null, Will contain Feedback keyonly if the feedback is against another feedback' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentFeedback', @level2type=N'COLUMN',@level2name=N'ContentFeedbackFeedbackKey'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentFeedback', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentFeedback', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentFeedback', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentFeedback', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentFeedback', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentFeedback', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentFeedback', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentFeedback', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentFeedback', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentFeedback', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [ContentChoiceOption]    Script Date: 08/15/2016 16:34:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentChoiceOption]') AND type in (N'U'))
BEGIN
CREATE TABLE [ContentChoiceOption](
	[ContentChoiceKey] [int] IDENTITY(1,1) NOT NULL,
	[ContentKey] [int] NOT NULL,
	[ContentChoiceSequenceNo] [int] NOT NULL,
	[ContentChoiceOptionDisplayName] [varchar](50) NULL,
	[ContentChoiceOptionDescription] [varchar](max) NOT NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_ContentChoiceOption_1] PRIMARY KEY CLUSTERED 
(
	[ContentChoiceKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentChoiceOption', N'COLUMN',N'ContentChoiceSequenceNo'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'The order in which the multiple choice option should appear' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentChoiceOption', @level2type=N'COLUMN',@level2name=N'ContentChoiceSequenceNo'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentChoiceOption', N'COLUMN',N'ContentChoiceOptionDisplayName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This will represent like a). or ii). along with option' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentChoiceOption', @level2type=N'COLUMN',@level2name=N'ContentChoiceOptionDisplayName'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentChoiceOption', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentChoiceOption', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentChoiceOption', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentChoiceOption', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentChoiceOption', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentChoiceOption', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentChoiceOption', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentChoiceOption', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentChoiceOption', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentChoiceOption', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [ContentBinaryData]    Script Date: 08/15/2016 16:34:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentBinaryData]') AND type in (N'U'))
BEGIN
CREATE TABLE [ContentBinaryData](
	[ContentBinaryDataKey] [int] IDENTITY(1,1) NOT NULL,
	[ContentKey] [int] NOT NULL,
	[ContentBinaryData] [varbinary](max) NOT NULL,
	[ContentThumbnailImage] [varbinary](max) NULL,
	[ContentBinaryDataFileName] [varchar](1000) NULL,
	[ContentBinaryDataType] [varchar](1000) NULL,
	[ContentTotalDownloads] [int] NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_ContentBinaryDataContent] PRIMARY KEY CLUSTERED 
(
	[ContentBinaryDataKey] ASC,
	[ContentKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentBinaryData', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentBinaryData', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentBinaryData', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentBinaryData', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentBinaryData', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentBinaryData', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentBinaryData', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentBinaryData', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentBinaryData', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentBinaryData', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  Table [ContentChoiceResponse]    Script Date: 08/15/2016 16:34:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[ContentChoiceResponse]') AND type in (N'U'))
BEGIN
CREATE TABLE [ContentChoiceResponse](
	[ContentChoiceKey] [int] NOT NULL,
	[ContentChoiceResponseUserKey] [int] NOT NULL,
	[ContentChoiceResponseText] [varchar](max) NOT NULL,
	[ContentChoiceResponsekDate] [datetime] NOT NULL,
	[ContentChoiceResponseUserName] [varchar](150) NOT NULL,
	[ContentChoiceResponseUserEmail] [varchar](150) NOT NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_ContentChoiceResponse_1] PRIMARY KEY CLUSTERED 
(
	[ContentChoiceKey] ASC,
	[ContentChoiceResponseUserKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentChoiceResponse', N'COLUMN',N'Sys_DeleteType'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentChoiceResponse', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentChoiceResponse', N'COLUMN',N'Sys_IsDeleted'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentChoiceResponse', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentChoiceResponse', N'COLUMN',N'Sys_OrganizationID'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentChoiceResponse', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentChoiceResponse', N'COLUMN',N'Sys_InitialPrimaryKeys'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentChoiceResponse', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'IvyDBAdmin', N'TABLE',N'ContentChoiceResponse', N'COLUMN',N'Sys_WorkstationName'))
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'IvyDBAdmin', @level1type=N'TABLE',@level1name=N'ContentChoiceResponse', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO
/****** Object:  ForeignKey [FK_AlertAndNotificationRecepientUser_AlertAndNotificationRegister]    Script Date: 08/15/2016 16:34:06 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_AlertAndNotificationRecepientUser_AlertAndNotificationRegister]') AND parent_object_id = OBJECT_ID(N'[AlertAndNotificationRecepientUser]'))
ALTER TABLE [AlertAndNotificationRecepientUser]  WITH CHECK ADD  CONSTRAINT [FK_AlertAndNotificationRecepientUser_AlertAndNotificationRegister] FOREIGN KEY([AlertNotificationKey])
REFERENCES [AlertAndNotificationRegister] ([AlertNotificationKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_AlertAndNotificationRecepientUser_AlertAndNotificationRegister]') AND parent_object_id = OBJECT_ID(N'[AlertAndNotificationRecepientUser]'))
ALTER TABLE [AlertAndNotificationRecepientUser] CHECK CONSTRAINT [FK_AlertAndNotificationRecepientUser_AlertAndNotificationRegister]
GO
/****** Object:  ForeignKey [FK_ContentBinaryData_ContentDataMaster]    Script Date: 08/15/2016 16:34:07 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentBinaryData_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentBinaryData]'))
ALTER TABLE [ContentBinaryData]  WITH CHECK ADD  CONSTRAINT [FK_ContentBinaryData_ContentDataMaster] FOREIGN KEY([ContentKey])
REFERENCES [ContentDataMaster] ([ContentKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentBinaryData_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentBinaryData]'))
ALTER TABLE [ContentBinaryData] CHECK CONSTRAINT [FK_ContentBinaryData_ContentDataMaster]
GO
/****** Object:  ForeignKey [FK_ContentChoiceOption_ContentDataMaster]    Script Date: 08/15/2016 16:34:07 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentChoiceOption_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentChoiceOption]'))
ALTER TABLE [ContentChoiceOption]  WITH CHECK ADD  CONSTRAINT [FK_ContentChoiceOption_ContentDataMaster] FOREIGN KEY([ContentKey])
REFERENCES [ContentDataMaster] ([ContentKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentChoiceOption_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentChoiceOption]'))
ALTER TABLE [ContentChoiceOption] CHECK CONSTRAINT [FK_ContentChoiceOption_ContentDataMaster]
GO
/****** Object:  ForeignKey [FK_ContentChoiceResponse_ContentChoiceOption]    Script Date: 08/15/2016 16:34:07 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentChoiceResponse_ContentChoiceOption]') AND parent_object_id = OBJECT_ID(N'[ContentChoiceResponse]'))
ALTER TABLE [ContentChoiceResponse]  WITH CHECK ADD  CONSTRAINT [FK_ContentChoiceResponse_ContentChoiceOption] FOREIGN KEY([ContentChoiceKey])
REFERENCES [ContentChoiceOption] ([ContentChoiceKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentChoiceResponse_ContentChoiceOption]') AND parent_object_id = OBJECT_ID(N'[ContentChoiceResponse]'))
ALTER TABLE [ContentChoiceResponse] CHECK CONSTRAINT [FK_ContentChoiceResponse_ContentChoiceOption]
GO
/****** Object:  ForeignKey [FK_ContentDataMaster_ContentTypeMaster]    Script Date: 08/15/2016 16:34:07 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentDataMaster_ContentTypeMaster]') AND parent_object_id = OBJECT_ID(N'[ContentDataMaster]'))
ALTER TABLE [ContentDataMaster]  WITH CHECK ADD  CONSTRAINT [FK_ContentDataMaster_ContentTypeMaster] FOREIGN KEY([ContentTypeKey])
REFERENCES [ContentTypeMaster] ([ContentTypeKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentDataMaster_ContentTypeMaster]') AND parent_object_id = OBJECT_ID(N'[ContentDataMaster]'))
ALTER TABLE [ContentDataMaster] CHECK CONSTRAINT [FK_ContentDataMaster_ContentTypeMaster]
GO
/****** Object:  ForeignKey [FK_ContentFeedback_ContentDataMaster]    Script Date: 08/15/2016 16:34:07 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentFeedback_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentFeedback]'))
ALTER TABLE [ContentFeedback]  WITH CHECK ADD  CONSTRAINT [FK_ContentFeedback_ContentDataMaster] FOREIGN KEY([ContentKey])
REFERENCES [ContentDataMaster] ([ContentKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentFeedback_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentFeedback]'))
ALTER TABLE [ContentFeedback] CHECK CONSTRAINT [FK_ContentFeedback_ContentDataMaster]
GO
/****** Object:  ForeignKey [FK_ContentImageData_ContentDataMaster]    Script Date: 08/15/2016 16:34:07 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentImageData_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentImageData]'))
ALTER TABLE [ContentImageData]  WITH CHECK ADD  CONSTRAINT [FK_ContentImageData_ContentDataMaster] FOREIGN KEY([ContentKey])
REFERENCES [ContentDataMaster] ([ContentKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentImageData_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentImageData]'))
ALTER TABLE [ContentImageData] CHECK CONSTRAINT [FK_ContentImageData_ContentDataMaster]
GO
/****** Object:  ForeignKey [FK_ContentRating_ContentDataMaster]    Script Date: 08/15/2016 16:34:07 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentRating_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentRating]'))
ALTER TABLE [ContentRating]  WITH CHECK ADD  CONSTRAINT [FK_ContentRating_ContentDataMaster] FOREIGN KEY([ContentKey])
REFERENCES [ContentDataMaster] ([ContentKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_ContentRating_ContentDataMaster]') AND parent_object_id = OBJECT_ID(N'[ContentRating]'))
ALTER TABLE [ContentRating] CHECK CONSTRAINT [FK_ContentRating_ContentDataMaster]
GO
/****** Object:  ForeignKey [FK__Feedback__FeedbackUser]    Script Date: 08/15/2016 16:34:07 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK__Feedback__FeedbackUser]') AND parent_object_id = OBJECT_ID(N'[Feedback]'))
ALTER TABLE [Feedback]  WITH CHECK ADD  CONSTRAINT [FK__Feedback__FeedbackUser] FOREIGN KEY([FeedbackUserKey])
REFERENCES [FeedbackUser] ([FeedbackUserKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK__Feedback__FeedbackUser]') AND parent_object_id = OBJECT_ID(N'[Feedback]'))
ALTER TABLE [Feedback] CHECK CONSTRAINT [FK__Feedback__FeedbackUser]
GO
/****** Object:  ForeignKey [FK_PersonProfileImage_Person]    Script Date: 08/15/2016 16:34:07 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_PersonProfileImage_Person]') AND parent_object_id = OBJECT_ID(N'[PersonProfileImage]'))
ALTER TABLE [PersonProfileImage]  WITH CHECK ADD  CONSTRAINT [FK_PersonProfileImage_Person] FOREIGN KEY([PersonKey])
REFERENCES [Person] ([PersonKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_PersonProfileImage_Person]') AND parent_object_id = OBJECT_ID(N'[PersonProfileImage]'))
ALTER TABLE [PersonProfileImage] CHECK CONSTRAINT [FK_PersonProfileImage_Person]
GO
/****** Object:  ForeignKey [FK_Sys_ActivityMaster_Sys_ActivityTypeMaster]    Script Date: 08/15/2016 16:34:08 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_ActivityMaster_Sys_ActivityTypeMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_ActivityMaster]'))
ALTER TABLE [Sys_ActivityMaster]  WITH CHECK ADD  CONSTRAINT [FK_Sys_ActivityMaster_Sys_ActivityTypeMaster] FOREIGN KEY([ActivityTypeKey])
REFERENCES [Sys_ActivityTypeMaster] ([ActivityTypeKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_ActivityMaster_Sys_ActivityTypeMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_ActivityMaster]'))
ALTER TABLE [Sys_ActivityMaster] CHECK CONSTRAINT [FK_Sys_ActivityMaster_Sys_ActivityTypeMaster]
GO
/****** Object:  ForeignKey [FK_Sys_RoleActivity_Sys_ActivityMaster]    Script Date: 08/15/2016 16:34:08 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_RoleActivity_Sys_ActivityMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_RoleActivity]'))
ALTER TABLE [Sys_RoleActivity]  WITH CHECK ADD  CONSTRAINT [FK_Sys_RoleActivity_Sys_ActivityMaster] FOREIGN KEY([RoleActivityKey])
REFERENCES [Sys_ActivityMaster] ([ActivityKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_RoleActivity_Sys_ActivityMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_RoleActivity]'))
ALTER TABLE [Sys_RoleActivity] CHECK CONSTRAINT [FK_Sys_RoleActivity_Sys_ActivityMaster]
GO
/****** Object:  ForeignKey [FK_Sys_RoleActivity_Sys_RoleMaster]    Script Date: 08/15/2016 16:34:08 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_RoleActivity_Sys_RoleMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_RoleActivity]'))
ALTER TABLE [Sys_RoleActivity]  WITH CHECK ADD  CONSTRAINT [FK_Sys_RoleActivity_Sys_RoleMaster] FOREIGN KEY([RoleKey])
REFERENCES [Sys_RoleMaster] ([RoleKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_RoleActivity_Sys_RoleMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_RoleActivity]'))
ALTER TABLE [Sys_RoleActivity] CHECK CONSTRAINT [FK_Sys_RoleActivity_Sys_RoleMaster]
GO
/****** Object:  ForeignKey [FK_Sys_TableMaster_Sys_ModuleMaster]    Script Date: 08/15/2016 16:34:08 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_TableMaster_Sys_ModuleMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_TableMaster]'))
ALTER TABLE [Sys_TableMaster]  WITH CHECK ADD  CONSTRAINT [FK_Sys_TableMaster_Sys_ModuleMaster] FOREIGN KEY([ModuleID])
REFERENCES [Sys_ModuleMaster] ([ModuleID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Sys_TableMaster_Sys_ModuleMaster]') AND parent_object_id = OBJECT_ID(N'[Sys_TableMaster]'))
ALTER TABLE [Sys_TableMaster] CHECK CONSTRAINT [FK_Sys_TableMaster_Sys_ModuleMaster]
GO
/****** Object:  ForeignKey [FK_User_Person]    Script Date: 08/15/2016 16:34:09 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_User_Person]') AND parent_object_id = OBJECT_ID(N'[User]'))
ALTER TABLE [User]  WITH CHECK ADD  CONSTRAINT [FK_User_Person] FOREIGN KEY([UserPersonKey])
REFERENCES [Person] ([PersonKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_User_Person]') AND parent_object_id = OBJECT_ID(N'[User]'))
ALTER TABLE [User] CHECK CONSTRAINT [FK_User_Person]
GO
/****** Object:  ForeignKey [FK_UserRole_Sys_OrganizationMaster]    Script Date: 08/15/2016 16:34:09 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_Sys_OrganizationMaster]') AND parent_object_id = OBJECT_ID(N'[UserOrganizationRole]'))
ALTER TABLE [UserOrganizationRole]  WITH CHECK ADD  CONSTRAINT [FK_UserRole_Sys_OrganizationMaster] FOREIGN KEY([UserOrganizationKey])
REFERENCES [Sys_OrganizationMaster] ([OrganizationID])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_Sys_OrganizationMaster]') AND parent_object_id = OBJECT_ID(N'[UserOrganizationRole]'))
ALTER TABLE [UserOrganizationRole] CHECK CONSTRAINT [FK_UserRole_Sys_OrganizationMaster]
GO
/****** Object:  ForeignKey [FK_UserRole_Sys_RoleMaster]    Script Date: 08/15/2016 16:34:09 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_Sys_RoleMaster]') AND parent_object_id = OBJECT_ID(N'[UserOrganizationRole]'))
ALTER TABLE [UserOrganizationRole]  WITH CHECK ADD  CONSTRAINT [FK_UserRole_Sys_RoleMaster] FOREIGN KEY([UserRoleKey])
REFERENCES [Sys_RoleMaster] ([RoleKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_Sys_RoleMaster]') AND parent_object_id = OBJECT_ID(N'[UserOrganizationRole]'))
ALTER TABLE [UserOrganizationRole] CHECK CONSTRAINT [FK_UserRole_Sys_RoleMaster]
GO
/****** Object:  ForeignKey [FK_UserRole_User]    Script Date: 08/15/2016 16:34:09 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_User]') AND parent_object_id = OBJECT_ID(N'[UserOrganizationRole]'))
ALTER TABLE [UserOrganizationRole]  WITH CHECK ADD  CONSTRAINT [FK_UserRole_User] FOREIGN KEY([UserKey])
REFERENCES [User] ([UserPersonKey])
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_UserRole_User]') AND parent_object_id = OBJECT_ID(N'[UserOrganizationRole]'))
ALTER TABLE [UserOrganizationRole] CHECK CONSTRAINT [FK_UserRole_User]
GO
